<?php

defined('SYSPATH') or die('No direct script access.');

class Controller_Adm_Autoclass extends Controller_Base_Backend {
	
	public function action_index(){
		
		$this->view->body->content = Smarty_View::factory('auto/show.tpl');
		$this->view->body->content->choose_table = Smarty_View::factory('auto/choose.tpl');
		$this->view->body->content->choose_table->table_array = Model_Autoclass::get_tables();
		if($this->request->post("table")){
			$this->view->body->content->choose_table->selected = $this->request->post("table");
			$this->view->body->content->code = Smarty_View::factory('auto/code.tpl');
			$this->view->body->content->code->model_name = ucfirst($this->request->post("table"));
			$this->view->body->content->code->table_name = $this->request->post("table");
			$this->view->body->content->code->fields = Model_Autoclass::get_fields($this->request->post("table"));
		}
		$this->response->body($this->view);
	}
}
